package group.sicher.log.recorder;

import group.sicher.log.model.HttpRecord;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Donald
 * @description
 * @date 2019-08-02
 **/
@Slf4j
public class HttpLogRecorder implements HttpRecorder {
    @Override
    public void record(HttpServletRequest request, HttpServletResponse response, long cost) {
        HttpRecord record = HttpRecord.of(request, response, cost);

        log.info("requestId: {}, ip: {}, path: {}, header: {}, method: {}, parameters: {}, requestBody: {}, status: {}, cost: {} ms",
                record.getRequestId(), record.getIp(), record.getPath(), record.getHeader(), record.getMethod(), record.getParameters(), record.getRequestBody(), record.getStatus(), record.getCost());
    }
}
